<html>
<head><meta charset="utf-8"><title>lazy normalization · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html">lazy normalization</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="196926011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196926011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196926011">(May 08 2020 at 17:33)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/71973" title="https://github.com/rust-lang/rust/pull/71973">https://github.com/rust-lang/rust/pull/71973</a></p>
<p>I am currently trying to remove <code>lazy_normalization_consts</code> by checking the <code>const_generics</code> flag instead.</p>



<a name="196926036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196926036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196926036">(May 08 2020 at 17:33)</a>:</h4>
<p>Doing this lead to a stack overflow for the following test:</p>
<div class="codehilite"><pre><span></span><code><span class="cp">#![feature(const_generics)]</span><span class="w"></span>
<span class="cp">#![allow(incomplete_features)]</span><span class="w"></span>

<span class="k">trait</span><span class="w"> </span><span class="n">Bar</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Bar</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">T</span><span class="p">]</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="c1">//~^ ERROR expected value, found type parameter `T`</span>

<span class="k">struct</span> <span class="nc">Foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">T</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">T</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">T</span><span class="p">]</span>: <span class="nc">Bar</span><span class="o">&lt;</span><span class="p">[();</span><span class="w"> </span><span class="n">T</span><span class="p">]</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Foo</span>::<span class="n">foo</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="196926122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196926122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196926122">(May 08 2020 at 17:34)</a>:</h4>
<p>With the following cycle:</p>
<div class="codehilite"><pre><span></span><code>[DEBUG rustc_infer::infer::resolve] OpportunisticVarResolver::fold_const(Const { ty: usize, val: Unevaluated(DefId(0:7 ~ issue_69654[317d]::{{impl}}[0]::{{constant}}[0]), [_], None) })
[DEBUG rustc_infer::infer::resolve] OpportunisticVarResolver::fold_ty(usize)
[DEBUG rustc_infer::infer::resolve] OpportunisticVarResolver::fold_ty(_)
[DEBUG rustc_infer::infer::resolve] OpportunisticVarResolver::fold_ty(())
</code></pre></div>



<a name="196926620"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196926620" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196926620">(May 08 2020 at 17:38)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="121053">@varkor</span> <span class="user-mention" data-user-id="116009">@nikomatsakis</span> do you have an idea where this might come from?</p>



<a name="196926638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196926638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196926638">(May 08 2020 at 17:38)</a>:</h4>
<p>Or more generally, how to debug this further</p>



<a name="196927186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196927186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196927186">(May 08 2020 at 17:43)</a>:</h4>
<p>This somehow creates an unevaluated const which has itself as a subst afaict</p>



<a name="196927526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196927526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196927526">(May 08 2020 at 17:45)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_infer/infer/resolve.rs#L40" title="https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_infer/infer/resolve.rs#L40">https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_infer/infer/resolve.rs#L40</a><br>
Should we short circuit here due to lazy normalization?</p>



<a name="196928025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196928025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196928025">(May 08 2020 at 17:49)</a>:</h4>
<p>^ That doesn't work <span aria-label="disappointed" class="emoji emoji-1f61e" role="img" title="disappointed">:disappointed:</span></p>



<a name="196928714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196928714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196928714">(May 08 2020 at 17:55)</a>:</h4>
<p>Will look at Const::Unevaluated creation for now</p>



<a name="196943243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196943243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196943243">(May 08 2020 at 19:57)</a>:</h4>
<p>oh no, <code>type_of</code> is probably at fault here <span aria-label="distraught" class="emoji emoji-1f629" role="img" title="distraught">:distraught:</span> I was actually the one who introduced this incorrect behavior :/ fu</p>



<a name="196946268"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196946268" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196946268">(May 08 2020 at 20:24)</a>:</h4>
<p>type_of?</p>



<a name="196946295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196946295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196946295">(May 08 2020 at 20:24)</a>:</h4>
<p>that  is, the test is not using <code>type_of</code></p>



<a name="196946299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196946299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196946299">(May 08 2020 at 20:25)</a>:</h4>
<p>(right?)</p>



<a name="196946343"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196946343" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196946343">(May 08 2020 at 20:25)</a>:</h4>
<p>This type of <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span>  <a href="https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_typeck/collect/type_of.rs#L273" title="https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_typeck/collect/type_of.rs#L273">https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_typeck/collect/type_of.rs#L273</a></p>



<a name="196946526"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196946526" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196946526">(May 08 2020 at 20:27)</a>:</h4>
<p>Some Node::Ty's have <code>Some(Res::Err)</code> without having an actual error, which is why I added this filter here</p>



<a name="196946769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196946769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196946769">(May 08 2020 at 20:29)</a>:</h4>
<p><code>Res::Err</code> without an actual error sounds like a bug in resolve/hir construction...</p>



<a name="196946880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196946880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196946880">(May 08 2020 at 20:30)</a>:</h4>
<p>agreed</p>



<a name="196946953"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196946953" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196946953">(May 08 2020 at 20:31)</a>:</h4>
<p>Hm, we currently create a lot of <code>Res::Err</code> without an associated <code>delay_span_bug</code> <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span> So while I agree,<br>
I wasn't able to fix it</p>



<a name="196948206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196948206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196948206">(May 08 2020 at 20:42)</a>:</h4>
<p>Bad news, <code>Node::Ty</code> aren't the only problem.</p>



<a name="196948321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196948321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196948321">(May 08 2020 at 20:43)</a>:</h4>
<p>for example</p>
<div class="codehilite"><pre><span></span><code><span class="c1">// run-pass</span>

<span class="cp">#![feature(const_generics)]</span><span class="w"></span>
<span class="c1">//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash</span>

<span class="k">trait</span><span class="w"> </span><span class="n">T</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">A</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">l</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">bool</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">usize</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">r</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">bool</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">bool</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">struct</span> <span class="nc">S</span><span class="p">;</span><span class="w"></span>

<span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="n">T</span><span class="o">&lt;</span><span class="n">N</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="n">S</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">l</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">M</span>: <span class="kt">bool</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">usize</span> <span class="p">{</span><span class="w"> </span><span class="n">N</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">r</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">M</span>: <span class="kt">bool</span><span class="o">&gt;</span><span class="p">()</span><span class="w"> </span>-&gt; <span class="kt">bool</span> <span class="p">{</span><span class="w"> </span><span class="n">M</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">   </span><span class="n">assert_eq</span><span class="o">!</span><span class="p">(</span><span class="o">&lt;</span><span class="n">S</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">T</span><span class="o">&lt;</span><span class="mi">123</span><span class="o">&gt;&gt;</span>::<span class="n">l</span>::<span class="o">&lt;</span><span class="kc">true</span><span class="o">&gt;</span><span class="p">(),</span><span class="w"> </span><span class="mi">123</span><span class="p">);</span><span class="w"></span>
<span class="w">   </span><span class="n">assert</span><span class="o">!</span><span class="p">(</span><span class="o">&lt;</span><span class="n">S</span><span class="w"> </span><span class="k">as</span><span class="w"> </span><span class="n">T</span><span class="o">&lt;</span><span class="mi">123</span><span class="o">&gt;&gt;</span>::<span class="n">r</span>::<span class="o">&lt;</span><span class="kc">true</span><span class="o">&gt;</span><span class="p">());</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>Has an incorrect <code>Res</code> as well:</p>
<div class="codehilite"><pre><span></span><code>PathSegment {
    ident: A#0,
    hir_id: Some(HirId {
        owner: DefId(0:10 ~ types_mismatch_const_args[317d]::a[0]), local_id: 27
    }),
    res: Some(Err),
....
</code></pre></div>



<a name="196949552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196949552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196949552">(May 08 2020 at 20:54)</a>:</h4>
<p>Would it be a  good idea to add a token with a private constructor to all these error variants?<br>
Similar to what I am doing here <a href="https://github.com/lcnr/computer/blob/8b8681dc83ca2df24e7d5bc5e1c96c9673ebd6a8/boulder/diagnostics/src/lib.rs#L20" title="https://github.com/lcnr/computer/blob/8b8681dc83ca2df24e7d5bc5e1c96c9673ebd6a8/boulder/diagnostics/src/lib.rs#L20">https://github.com/lcnr/computer/blob/8b8681dc83ca2df24e7d5bc5e1c96c9673ebd6a8/boulder/diagnostics/src/lib.rs#L20</a></p>



<a name="196950416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196950416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196950416">(May 08 2020 at 21:03)</a>:</h4>
<p>I have to admit I'm kind of confused as to what is going on here</p>



<a name="196950425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196950425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196950425">(May 08 2020 at 21:03)</a>:</h4>
<p>I'd have to read more into the code to understand what I think is the right solution</p>



<a name="196950992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196950992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196950992">(May 08 2020 at 21:09)</a>:</h4>
<p>This is something I should be able to either fix myself, or at least get far enough to be certain where this failure comes from.</p>
<p>If my current thinking is correct this will be both hard to fix and somewhat orthogonal to lazy normalization.<br>
IMO it may be best to disable this test for now and solve this problem afterwards in this case</p>



<a name="196960097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196960097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196960097">(May 08 2020 at 23:01)</a>:</h4>
<p><code>Res::Err</code> is not actually the culprit here.<br>
Which is both good, because we can fix this bug as part of this PR, and bad, because I still haven't done so <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> <br>
I believe it's a wrong interaction here <a href="https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_middle/ty/sty.rs#L2280" title="https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_middle/ty/sty.rs#L2280">https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_middle/ty/sty.rs#L2280</a></p>
<p>While creates a <code>ConstKind::Unevaluated</code> with a subst which indirectly references itself.<br>
Will look into this further tomorrow</p>



<a name="196960126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196960126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mark-i-m <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196960126">(May 08 2020 at 23:01)</a>:</h4>
<blockquote>
<p>Would it be a good idea to add a token with a private constructor to all these error variants?</p>
</blockquote>
<p>(aside: I'm actually doing this for <code>TyKind::Error</code> in <a href="https://github.com/rust-lang/rust/issues/70551" title="https://github.com/rust-lang/rust/issues/70551">#70551</a>)</p>



<a name="196984126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196984126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196984126">(May 09 2020 at 10:16)</a>:</h4>
<blockquote>
<p>I believe it's a wrong interaction here <a href="https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_middle/ty/sty.rs#L2280" title="https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_middle/ty/sty.rs#L2280">https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_middle/ty/sty.rs#L2280</a></p>
</blockquote>
<p>tbh I don't know where this problem comes from <span aria-label="distraught" class="emoji emoji-1f629" role="img" title="distraught">:distraught:</span></p>
<p>Somewhat minimized (this has a stack overflow):</p>
<div class="codehilite"><pre><span></span><code><span class="cp">#![feature(const_generics)]</span><span class="w"></span>
<span class="cp">#![allow(incomplete_features)]</span><span class="w"></span>

<span class="k">trait</span><span class="w"> </span><span class="n">Bar</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Bar</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="p">{</span><span class="mi">7</span><span class="p">}]</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="k">struct</span> <span class="nc">Foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">N</span><span class="o">&gt;</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="p">]</span>: <span class="nc">Bar</span><span class="o">&lt;</span><span class="p">[();</span><span class="w"> </span><span class="n">N</span><span class="p">]</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Foo</span>::<span class="n">foo</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="196984132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196984132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196984132">(May 09 2020 at 10:16)</a>:</h4>
<p>This does not:</p>
<div class="codehilite"><pre><span></span><code><span class="c1">// run-pass</span>
<span class="cp">#![feature(const_generics)]</span><span class="w"></span>
<span class="cp">#![allow(incomplete_features)]</span><span class="w"></span>

<span class="k">trait</span><span class="w"> </span><span class="n">Bar</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Bar</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="mi">7</span><span class="p">]</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="c1">// ^ removing the braces around 7</span>

<span class="k">struct</span> <span class="nc">Foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">N</span><span class="o">&gt;</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="p">]</span>: <span class="nc">Bar</span><span class="o">&lt;</span><span class="p">[();</span><span class="w"> </span><span class="n">N</span><span class="p">]</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Foo</span>::<span class="n">foo</span><span class="p">();</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>edit: probably because we special case literals in <code>from_anon_const</code> and this<br>
bug requires the impl to contain a <code>ConstKind::Unevaluated</code></p>



<a name="196984234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196984234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196984234">(May 09 2020 at 10:20)</a>:</h4>
<p>And this also works:</p>
<div class="codehilite"><pre><span></span><code><span class="c1">// run-pass</span>
<span class="cp">#![feature(const_generics)]</span><span class="w"></span>
<span class="cp">#![allow(incomplete_features, unused_braces)]</span><span class="w"></span>

<span class="k">trait</span><span class="w"> </span><span class="n">Bar</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Bar</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="p">{</span><span class="mi">7</span><span class="p">}]</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>

<span class="k">struct</span> <span class="nc">Foo</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="k">impl</span><span class="o">&lt;</span><span class="k">const</span><span class="w"> </span><span class="n">N</span>: <span class="kt">usize</span><span class="o">&gt;</span><span class="w"> </span><span class="n">Foo</span><span class="o">&lt;</span><span class="n">N</span><span class="o">&gt;</span><span class="w"></span>
<span class="k">where</span><span class="w"></span>
<span class="w">    </span><span class="p">[</span><span class="kt">u8</span><span class="p">;</span><span class="w"> </span><span class="n">N</span><span class="p">]</span>: <span class="nc">Bar</span><span class="o">&lt;</span><span class="p">[();</span><span class="w"> </span><span class="n">N</span><span class="p">]</span><span class="o">&gt;</span><span class="p">,</span><span class="w"></span>
<span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span><span class="p">{}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Foo</span>::<span class="o">&lt;</span><span class="p">{</span><span class="mi">7</span><span class="p">}</span><span class="o">&gt;</span>::<span class="n">foo</span><span class="p">();</span><span class="w"></span>
<span class="w">    </span><span class="c1">// ^ turbofish to the rescue</span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="196990075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/196990075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#196990075">(May 09 2020 at 12:45)</a>:</h4>
<p>I believe that the lowering <code>hir -&gt; Ty/Const</code> is not at fault here but don't really know how to progress further here.</p>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> <span class="user-mention" data-user-id="121053">@varkor</span> can you help me out here or are you fine with disabling this test for now?</p>



<a name="197010558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/197010558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#197010558">(May 09 2020 at 20:16)</a>:</h4>
<p>might be related to <a href="https://github.com/rust-lang/rust/issues/68104" title="https://github.com/rust-lang/rust/issues/68104">https://github.com/rust-lang/rust/issues/68104</a></p>



<a name="197053760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/197053760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> varkor <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#197053760">(May 10 2020 at 12:51)</a>:</h4>
<p>I'm happy to disable tests involving specialisation for const parameters for now: there are unanswered questions about how exactly it should work, and we definitely haven't put any effort into deliberately making it work yet.</p>



<a name="197056713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/197056713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#197056713">(May 10 2020 at 13:53)</a>:</h4>
<p>What's the best way to do this? Should I just remove the test in my PR and open an issue for it?</p>



<a name="197838209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/lazy%20normalization/near/197838209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/lazy.20normalization.html#197838209">(May 17 2020 at 08:47)</a>:</h4>
<p><a href="/user_uploads/4715/_SP9KETJ8U9QMz_QrLADLUal/Screenshot-from-2020-05-17-10-46-37.png">cursed</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/_SP9KETJ8U9QMz_QrLADLUal/Screenshot-from-2020-05-17-10-46-37.png" title="cursed"><img src="/user_uploads/4715/_SP9KETJ8U9QMz_QrLADLUal/Screenshot-from-2020-05-17-10-46-37.png"></a></div>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>